package com.woniu.controller;

import com.github.pagehelper.PageInfo;
import com.woniu.common.CommonResult;

import com.woniu.pojo.AdminInformation;
import com.woniu.service.AdminService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;


import java.util.List;

/**
 * @author 张昊天
 * @date 2020/3/21 15:42
 */
@Controller
@RequestMapping("/admin")
public class AdminController {

    @Autowired
    private AdminService adminService;

    @RequestMapping("/list")
    @ResponseBody
    public CommonResult list(@RequestParam(value="page",defaultValue = "1",required = false) Integer currentPage,
                             @RequestParam(value="limit",defaultValue = "5",required = false) Integer pageSize){
        PageInfo info=null;
        try {
            List<AdminInformation> list=adminService.findAdminByPage(currentPage,pageSize);
            info=new PageInfo(list);
            return CommonResult.success();
        } catch (Exception e) {
            e.printStackTrace();
            return CommonResult.failed();
        }


    }


}
